<?php
require_once('../../../inc/header.inc.php');
require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
$db=mysql_connect(DATABASE_HOST,DATABASE_USER,DATABASE_PASS);
mysql_query("SET NAMES 'utf8'");
$userid = (int)$_COOKIE['memberID'];
if ($db==FALSE)
die ("errore di connessione");
mysql_select_db(DATABASE_NAME,$db) or die ("errore selezione database");
$id=$_POST['id'];
$query="SELECT * FROM bx_spy_data WHERE id=$id";
$resultquery=mysql_query($query,$db) or die(mysql_error());
$rowquery=mysql_fetch_row($resultquery);
if ($rowquery[1]==$userid OR $rowquery[2]==$userid OR isAdmin() OR isModerator()) 
{
 $querydx="DELETE FROM bx_spy_data WHERE id=$id";
 $resultquerydx=mysql_query($querydx,$db) or die(mysql_error());
 $query2="DELETE FROM commenti_spy_data WHERE data=$id";
 $resultquery2=mysql_query($query2,$db) or die(mysql_error());
 $query3="DELETE FROM ibdw_likethis WHERE id_notizia=$id AND typelement =''";
 $resultquery3=mysql_query($query3,$db) or die(mysql_error());
}
else {include 'alert.php';}
?>